<?php
/**
 * Created by PhpStorm.
 * User: De Niro
 * Date: 2015/5/11
 * Time: 12:49
 */
require_once("../api.php");
session_start();
function getRandChar($length){
    $str = null;
    $strPol = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
    $max = strlen($strPol)-1;

    for($i=0;$i<$length;$i++){
        $str.=$strPol[rand(0,$max)];//rand($min,$max)生成介于min和max两个数之间的一个随机整数
    }
    return $str;
}
function getExtension($file){
    return strrchr($file, '.');
}
if ( !empty( $_FILES ) ) {

    $tempPath = $_FILES[ 'file' ][ 'tmp_name' ];
    $uploadPath =  getRandChar(10).date('YmdHis'). getExtension($_FILES[ 'file' ][ 'name' ]);

    move_uploaded_file( $tempPath, '../assets/runTime/img/'.$uploadPath );
    $iconPath ='runTime/img/'.$uploadPath;
    ajaxJSON( true, "success" , $iconPath);

} else {
    echo ajaxJSON( false, "fail" );
}